﻿
layui.use(['form'], function () {
    var form = layui.form;
    var cityDom = $("#SortCity");
    var ProvinceDom = $("#Province");
    //监听事件
    form.on('select(column)', function (data) {
        if (cityDom) {
            ProvinceRender(cityDom, data.value);
        }
    });
    //省级选择
    var ProvinceRender = function (obj, data) {
        var d = [];
        d.push(data);
        var param = { ProvinceIDs: d }

        $.ajax({
            type: "post",
            url: "/Sort/SelectCiteList",
            data: param,
            dataType: "json",
            success: function (res) {
                $(obj).html('');
                if (res.code == 0) {
                    if (res.data) {
                        for (var i in res.data[0].Cities) {
                            $(obj).append('<option value= ' + res.data[0].Cities[i].CityID + '>' + res.data[0].Cities[i].CityName + '</option>');
                        }
                    }
                }
                else {
                    $(obj).html('');
                    $(obj).append('<option value="">请选择省</option>');
                }
                form.render('select');
            }
        });
    }
})
